import {getWxConfigSign_data} from "../../api/wxA";
import {useWxSDK} from "./userWxSDK";
import {H5URL} from "../../config/config";

export function useWxShare(shareConfig: {
    title: string;
    imgUrl: string;
    desc: string;
    link: string;
}) {
    const { initConfig, setShareInfo, isiOSWechat } = useWxSDK();
    let shareUrl = location.href.split('#')[0];
    if (isiOSWechat()) {
        shareUrl = location.origin + '' + location.pathname
    }
    // todo
    getWxConfigSign_data( shareUrl).then((config: any) => {
        initConfig(config).then(() => {
            setShareInfo({
                ...shareConfig
            });
        });
    });
}
